package com.ruoyi.web.controller.front;

import java.util.List;

import com.ruoyi.front.domain.ClasssicCases;
import com.ruoyi.front.service.IClasssicCasesService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.front.domain.ClasssicCasesProposal;
import com.ruoyi.front.service.IClasssicCasesProposalService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 典型案例问题解决建议Controller
 * 
 * @author ruoyi
 * @date 2020-11-07
 */
@Controller
@RequestMapping("/front/casesProposal")
public class ClasssicCasesProposalController extends BaseController
{
    private String prefix = "front/casesProposal";

    @Autowired
    private IClasssicCasesProposalService classsicCasesProposalService;
    @Autowired
    private IClasssicCasesService classsicCasesService;

    @RequiresPermissions("front:casesProposal:view")
    @GetMapping()
    public String casesProposal()
    {
        return prefix + "/casesProposal";
    }

    /**
     * 查询典型案例问题解决建议列表
     */
    @RequiresPermissions("front:casesProposal:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ClasssicCasesProposal classsicCasesProposal)
    {
        startPage();
        List<ClasssicCasesProposal> list = classsicCasesProposalService.selectClasssicCasesProposalList(classsicCasesProposal);
        return getDataTable(list);
    }

    /**
     * 导出典型案例问题解决建议列表
     */
    @RequiresPermissions("front:casesProposal:export")
    @Log(title = "典型案例问题解决建议", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ClasssicCasesProposal classsicCasesProposal)
    {
        List<ClasssicCasesProposal> list = classsicCasesProposalService.selectClasssicCasesProposalList(classsicCasesProposal);
        ExcelUtil<ClasssicCasesProposal> util = new ExcelUtil<ClasssicCasesProposal>(ClasssicCasesProposal.class);
        return util.exportExcel(list, "casesProposal");
    }

    /**
     * 新增典型案例问题解决建议
     */
    @GetMapping("/add")
    public String add(ModelMap mmap)
    {
        mmap.put("classsicCasesList", classsicCasesService.selectClasssicCasesList(new ClasssicCases()));
        return prefix + "/add";
    }

    /**
     * 新增保存典型案例问题解决建议
     */
    @RequiresPermissions("front:casesProposal:add")
    @Log(title = "典型案例问题解决建议", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ClasssicCasesProposal classsicCasesProposal)
    {
        return toAjax(classsicCasesProposalService.insertClasssicCasesProposal(classsicCasesProposal));
    }

    /**
     * 修改典型案例问题解决建议
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ClasssicCasesProposal classsicCasesProposal = classsicCasesProposalService.selectClasssicCasesProposalById(id);
        mmap.put("classsicCasesProposal", classsicCasesProposal);
        mmap.put("classsicCasesList", classsicCasesService.selectClasssicCasesList(new ClasssicCases()));
        return prefix + "/edit";
    }

    /**
     * 修改保存典型案例问题解决建议
     */
    @RequiresPermissions("front:casesProposal:edit")
    @Log(title = "典型案例问题解决建议", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ClasssicCasesProposal classsicCasesProposal)
    {
        return toAjax(classsicCasesProposalService.updateClasssicCasesProposal(classsicCasesProposal));
    }

    /**
     * 删除典型案例问题解决建议
     */
    @RequiresPermissions("front:casesProposal:remove")
    @Log(title = "典型案例问题解决建议", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(classsicCasesProposalService.deleteClasssicCasesProposalByIds(ids));
    }
}
